<template>
    <div class="modal fade" id="mortgageModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
      <div class="modal-dialog">
        <div class="modal-content">
          	<div class="modal-header">
            	<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
            	<h4 class="modal-title" id="myModalLabel">按揭状态变更</h4>
          	</div>
          	<div class="modal-body">
          	 	<div class="form-horizontal">
          	 		<div class="form-group">
	                  <label class="col-md-4 col-sm-2 control-label">按揭状态：</label>
						<div class="col-md-8 col-sm-10">
							<select class="form-control" v-model="params.mortgageStatus">
								<option value="1" v-res="{code:'menu_0005_0001_0008_0001'}">按揭未放款</option>
								<option value="2" v-res="{code:'menu_0005_0001_0008_0002'}">按揭已放款</option>
								<option value="9" v-res="{code:'menu_0005_0001_0008_0003'}">无需按揭</option>
							</select>
						</div>
	                </div>
	                <div class="form-group">
	                  <label for="" class="col-sm-4 control-label">备注信息：</label>
	                  <div class="col-sm-8">
	                    <textarea rows="5" class="form-control" v-model="params.remark" placeholder="请填写备注信息"></textarea>
	                  </div>
	                </div>
	            </div>
          	</div>
          	<div class="modal-footer">
            	<button type="button" class="btn checkedBtn"  @click="save">确定</button>
				<button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
          	</div>
        </div>
      </div>
    </div>
</template>

<script>
	export default{
		//接收父组件的绑定值
		props: ["mortgageModal"],
		data() {
			return {
				//机构信息对象
				params: {
				    id:'',
                    mortgageStatus:'',
					remark: ''
				}
			}
		},
		methods: {
            save: function() {
                const _self = this;
                const url = this.utilHelper.apiUrl+'/api/changeCPMortgage';
                const body = {};
                if(!_self.params.mortgageStatus){
                    layer.msg("请选择按揭状态");
                    return;
				}
                _self.params.id = this.mortgageModal.id;
                body.params = _self.params;
                _self.$http.post(url,body).then((response) =>{
                    const res = response.body.resData;
                    if(res.result == '1') {
                        layer.msg("变更成功");
                        $('#mortgageModal').modal('hide');
                        _self.$emit('saveMortgageListener');
                    }else {
                        layer.msg("变更失败");
                    }
                },(response)=>{
                    layer.msg("系统异常");
                });
			}
		}
	}
</script>